package org.otherworld.property;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Properties;

public class PropertyLoader {
	private static final String MESSAGE_PROPERTIES = "properties/messages.properties";
	private static final String SYSTEM_PROPERTIES = "properties/system.properties";
	private Properties properties;
	private Hashtable<String,Object> messageHash;
	private Hashtable<String,Object> systemHash;
	public PropertyLoader() throws IOException,FileNotFoundException{
		
		this.properties = new Properties();
		this.properties.load(new FileInputStream(MESSAGE_PROPERTIES));
		messageHash = new Hashtable<String,Object>();
		Iterator<Object> propIter = this.properties.keySet().iterator();
		Object key;
		Object value;
		while (propIter.hasNext()) {
			key = propIter.next();
			value = this.properties.getProperty(key.toString());
			messageHash.put(key.toString(), value);
		}
		
		this.properties = null;
		this.properties = new Properties();
		this.properties.load(new FileInputStream(SYSTEM_PROPERTIES));
		systemHash = new Hashtable<String,Object>();
		Iterator<Object> sysIter = this.properties.keySet().iterator();
		while (sysIter.hasNext()) {
			key = sysIter.next();
			value = this.properties.getProperty(key.toString());
			systemHash.put(key.toString(), value);
		}		
		
	}
	
	public Hashtable<String,Object> getProperties() {
		return this.messageHash;
	}
	
	public Hashtable<String,Object> getSystemProperties() {
		return this.systemHash;
	}
	
	
}
